package com.rabbiter.oes.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.rabbiter.oes.entity.ExamManage;
import com.rabbiter.oes.entity.MultiQuestion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

//选择题
@Mapper
public interface MultiQuestionMapper extends BaseMapper<MultiQuestion> {

    /**
     * 某科目选择题个数
     * @param subjectId
     * @return
     */
    default Long selectCountBysubjectId(String subjectId) {
        return selectCount(Wrappers.lambdaQuery(MultiQuestion.class).eq(MultiQuestion::getSubjectId, subjectId));
    }

    @Select("select questionId from multi_question order by rand() desc limit #{pageNo}")
    List<Integer> findBySubject(@Param("pageNo") Integer pageNo);

}
